#include <stdio.h>
#include "main.h"

int showcontact(FILE* file, struct contact data[], int* p_index)
{
	int i, j;
	if ((*p_index) < 0){
		puts("You have no records to be shown.");
		return 0;
	}
	else {

		for (i = 0; i < (*p_index); i++){ 
			printf("\n");
			printf("\nContact : %d\n", i + 1);
			j = 0;
			printf("Name:");
			while (data[i].name[j] != '\0'){
				printf("%c", data[i].name[j]);
				j++;
			}
			printf("\n");
			printf("Age:");
			printf("%d", data[i].age);
			printf("\n");
			j = 0;
			printf("Tel:");
			while (data[i].tel[j] != '\0'){
				printf("%c", data[i].tel[j]);
				j++;
			}
			printf(" ");
		}
		return 0;
	}
}
